package com.gly091020.client;

import com.gly091020.ChineseChestFun;
import com.gly091020.util.ChineseChestNetworkID;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;

public class ChineseChestClient implements ClientModInitializer {

    @Override
    public void onInitializeClient() {
        ClientPlayNetworking.registerGlobalReceiver(ChineseChestNetworkID.OPEN_SCREEN, (minecraftClient, clientPlayNetworkHandler, packetByteBuf, packetSender) -> {
            var p = packetByteBuf.readBlockPos();
            var s = packetByteBuf.readLong();
            minecraftClient.execute(() -> PoemFillScreen.open(ChineseChestFun.getRandomPoem(), p, s));
        });
    }
}
